<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>检测对象类型</title>
</head>

<body>
    <p></p>
    <script>
        let str1 = new String('string1');
        str1.test1 = 'test1';
        console.log(str1.test1); // "test1"
        console.log(typeof (str1)); // object
        console.log(str1.length); // 7
        let str2 = 'string2';
        str2.test2 = 'test2';
        console.log(str2.test2); // undefined
        console.log(typeof (str2)); // String
        console.log(str2.length); // 7
    </script>
</body>

</html>